use quote::quote;
use crate::{utils, extract::PathSegment};

pub fn generate_segements_code(path: &[PathSegment]) -> proc_macro2::TokenStream {
    let aqua = utils::get_aqua_path();

    let segments = path
        .iter()
        .map(|seg| {
            match seg {
                PathSegment::Param(name) => {
                    let name = name.to_string();
                    quote! {
                        #aqua::server::HttpRouteSegment::Param(#name.to_string())
                    }
                }
                PathSegment::Static(name) => {
                    quote! {
                        #aqua::server::HttpRouteSegment::Static(#name.to_string())
                    }
                }
            }
        });

    quote! {
        let segments = vec![#(#segments),*];
    }
}
